import Layout from '@/views/layout/Layout';

// 控制这系列页面的权限
const authData = {
  supplierManage: ['medium:supplier:read'], // 销售供应商
  // supplier: ['medium:supplierAudit:read'],
  commerceSupplier: ['crm:commerceSupplier:read'], // 有赞供应商
  mengliSuppliers: ['mengli:supplier:read', 'mengli:supplier:admin'], // 萌力供应商
  filter: ['crm:filter:read'], // 达人初筛
  signUp: ['signUp:signUp:read'], // 签约内审
  termination: ['crm:termination:read'], // 达人解约
  upOnline: ['crm:upOline:read'], // 达人上刊
  flyUser: ['crm:flyUser:read'], // 飞来用户
  flyNotice: ['crm:flyNotice:read'], // 飞来询单
  flyPrice: ['crm:flyPrice:read'], // 飞来询价
  question: ['crm:question:read'] // 询单题库
};
let pageAllAuth = [];
for (const key in authData) {
  pageAllAuth = pageAllAuth.concat(authData[key]);
}

// 供应
const supplierRouter = [{
  path: '/supplierPage',
  component: Layout,
  redirect: '/supplierPage/index',
  name: 'supplierPage',
  meta: { title: '供应', icon: 'sidebar-supplier', authControl: pageAllAuth },
  children: [
    // 以下页面在侧边栏中会展示在 "供应商" tab之下
    {
      path: 'index',
      parentName: '供应商',
      name: 'supplierManage',
      component: () => import('@/views/supplierManage/index'),
      meta: { title: '飞博供应商', keepAlive: true, isChange: true, authControl: authData.supplierManage, headerBarShow: false }
    },
    {
      path: 'commerceSupplier',
      parentName: '供应商',
      name: 'commerceSupplier',
      component: () => import('@/views/commerce/supplier'),
      meta: { title: '有赞供应商', keepAlive: true, isChange: true, headerBarShow: false, authControl: authData.commerceSupplier } // headerBarShow 为true显示头像
    },
    {
      path: 'mengliSuppliers',
      parentName: '供应商',
      name: 'mengliSuppliers',
      component: () => import('@/views/mengliPlanet/supplier/index'),
      meta: { keepAlive: true, isChange: true, title: '萌力供应商', headerBarShow: false, authControl: authData.mengliSuppliers }
    },
    // 以下页面在侧边栏中会展示在 "签约" tab之下
    {
      path: 'filter',
      component: () => import('@/views/filter/index'),
      name: 'filter',
      parentName: '达人签约',
      meta: { title: '达人初筛', authControl: authData.filter, keepAlive: true, isChange: true, headerBarShow: false }
    },
    {
      path: 'signUp',
      component: () => import('@/views/signUp/index'),
      name: 'signUp',
      parentName: '达人签约',
      meta: { title: '签约内审', authControl: authData.signUp, keepAlive: true, isChange: true, headerBarShow: false }
    },
    {
      path: 'upOnline',
      component: () => import('@/views/upOnline/index'),
      name: 'upOnline',
      parentName: '达人签约',
      meta: { title: '达人上刊', authControl: authData.upOnline, keepAlive: true, isChange: true, headerBarShow: false }
    },
    {
      path: 'termination',
      component: () => import('@/views/termination/index'),
      name: 'termination',
      parentName: '达人签约',
      meta: { title: '达人解约', authControl: authData.termination, keepAlive: true, isChange: true, headerBarShow: false }
    },
    // 以下页面在侧边栏中会展示在 "飞来" tab之下
    {
      path: 'flyUser',
      component: () => import('@/views/flyUser/index'),
      name: 'flyUser',
      parentName: '飞来通告',
      meta: { title: '飞来用户', authControl: authData.flyUser, keepAlive: true, isChange: true, headerBarShow: false }
    },
    {
      path: 'flyNotice',
      component: () => import('@/views/flyNotice/index'),
      name: 'flyNotice',
      parentName: '飞来通告',
      meta: { title: '飞来询单', authControl: authData.flyNotice, keepAlive: true, isChange: true, headerBarShow: false }
    },
    {
      path: 'flyPrice',
      component: () => import('@/views/flyPrice/index'),
      name: 'flyPrice',
      parentName: '飞来通告',
      meta: { title: '飞来询价', authControl: authData.flyPrice, keepAlive: true, isChange: true, headerBarShow: false }
    },
    {
      path: 'question',
      component: () => import('@/views/question/index'),
      name: 'question',
      parentName: '飞来通告',
      meta: { title: '询单题库', authControl: authData.question, keepAlive: true, isChange: true, headerBarShow: false }
    },
    /**
     * 内页
     */
    {
      path: 'terminationCreate',
      component: () => import('@/views/termination/create'),
      name: 'terminationCreate',
      meta: { title: '达人解约', headerBarShow: true, activeMenu: '/supplierPage/termination' },
      hidden: true
    },
    {
      path: 'terminationEdit/:id',
      component: () => import('@/views/termination/create'),
      name: 'terminationEdit',
      meta: { title: '达人解约', headerBarShow: true, activeMenu: '/supplierPage/termination' },
      hidden: true
    },
    {
      path: 'terminationDetail',
      component: () => import('@/views/termination/detail/index'),
      name: 'terminationDetail',
      meta: { title: '达人解约详情', headerBarShow: true, activeMenu: '/supplierPage/termination' },
      hidden: true
    },
    {
      path: 'upOnlineCreate',
      component: () => import('@/views/upOnline/create'),
      name: 'upOnlineCreate',
      meta: { title: '达人上刊', headerBarShow: true, activeMenu: '/supplierPage/upOnline' },
      hidden: true
    },
    {
      path: 'upOnlineEdit',
      component: () => import('@/views/upOnline/create'),
      name: 'upOnlineEdit',
      meta: { title: '达人上刊', headerBarShow: true, activeMenu: '/supplierPage/upOnline' },
      hidden: true
    },
    /** 销售供应商内页 */
    /* 飞博供应商 */
    {
      path: 'supplierManageDetail/:id',
      name: 'supplierManageDetail',
      hidden: true,
      component: () => import('@/views/supplierManage/detail/index'),
      meta: { title: '供应商详情', headerBarShow: true, activeMenu: '/supplierPage/index' }
    },
    // {
    //   path: 'supplierManageAdd',
    //   name: 'supplierManageAdd',
    //   hidden: true,
    //   component: () => import('@/views/supplierManage/create/index'),
    //   meta: { title: '新建供应商', headerBarShow: true, hideHeaderBarTitle: true, activeMenu: '/supplierPage/index' }
    // },
    /** 有赞供应商 */
    {
      path: 'commerceSupplierCreate',
      name: 'commerceSupplierCreate',
      component: () => import('@/views/commerce/supplier/create'),
      hidden: true,
      meta: { title: '新增有赞供应商', keepAlive: false, headerBarShow: true, activeMenu: '/supplierPage/commerceSupplier' } // headerBarShow 为true显示头像
    },
    {
      path: 'supplierEdit/:id',
      name: 'commerceSupplierEdit',
      component: () => import('@/views/commerce/supplier/create'),
      hidden: true,
      meta: { title: '编辑有赞供应商', keepAlive: false, headerBarShow: true, activeMenu: '/supplierPage/commerceSupplier' } // headerBarShow 为true显示头像
    },
    {
      path: 'supplierDetail/:id',
      name: 'commerceSupplierDetail',
      component: () => import('@/views/commerce/supplier/detail'),
      hidden: true,
      meta: { title: '有赞供应商详情', keepAlive: false, headerBarShow: true, activeMenu: '/supplierPage/commerceSupplier' } // headerBarShow 为true显示头像
    },
    /** 萌力供应商 */
    {
      path: 'createSupplier',
      name: 'mengliCreateSupplier',
      component: () => import('@/views/mengliPlanet/supplier/create'),
      meta: { title: '新建供应商', isContact: false, isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/supplierPage/mengliSuppliers' },
      hidden: true
    },
    {
      path: 'editSupplier/:id',
      name: 'mengliEditSupplier',
      hidden: true,
      component: () => import('@/views/mengliPlanet/supplier/create'),
      meta: { title: '编辑供应商', headerBarShow: true, activeMenu: '/supplierPage/mengliSuppliers' }
    },
    {
      path: 'mengliSupplierDetail/:id',
      name: 'mengliSupplierDetail',
      hidden: true,
      component: () => import('@/views/mengliPlanet/supplier/mengliSupplierDetial'),
      meta: { title: '供应商详情', headerBarShow: true, activeMenu: '/supplierPage/mengliSuppliers' }
    },
    {
      path: 'signUpDetail',
      component: () => import('@/views/signUp/detail/index'),
      name: 'signUpDetail',
      meta: { title: '签约内审详情', headerBarShow: true, activeMenu: '/supplierPage/signUp' },
      hidden: true
    },
    {
      path: 'signUpCreate',
      component: () => import('@/views/signUp/create/index'),
      name: 'signUpCreate',
      meta: { title: '签约内审', headerBarShow: true, activeMenu: '/supplierPage/signUp' },
      hidden: true
    },
    {
      path: 'signUpEdit/:id',
      component: () => import('@/views/signUp/create/index'),
      name: 'signUpEdit',
      meta: { title: '签约内审', headerBarShow: true, activeMenu: '/supplierPage/signUp' },
      hidden: true
    },
    {
      path: 'filterCreate',
      component: () => import('@/views/filter/create/index'),
      name: 'filterCreate',
      meta: { title: '达人初筛', headerBarShow: true, activeMenu: '/supplierPage/filter' },
      hidden: true
    },
    {
      path: 'filterEdit/:id',
      component: () => import('@/views/filter/create/index'),
      name: 'filterEdit',
      meta: { title: '达人初筛', headerBarShow: true, activeMenu: '/supplierPage/filter' },
      hidden: true
    },
    {
      path: 'filterDetail',
      component: () => import('@/views/filter/detail/index'),
      name: 'filterDetail',
      meta: { title: '达人初筛详情', headerBarShow: true, activeMenu: '/supplierPage/filter' },
      hidden: true
    },
    {
      path: 'flyUserDetail',
      component: () => import('@/views/flyUser/detail/index'),
      name: 'flyUserDetail',
      meta: { title: '飞来用户详情', headerBarShow: true, activeMenu: '/supplierPage/flyUser' },
      hidden: true
    },
    {
      path: 'flyNoticeDetail',
      component: () => import('@/views/flyNotice/detail/index'),
      name: 'flyNoticeDetail',
      meta: { title: '询单详情', headerBarShow: true, activeMenu: '/supplierPage/flyNotice' },
      hidden: true
    },
    {
      path: 'flyNoticeEdit',
      component: () => import('@/views/flyNotice/create/index'),
      name: 'flyNoticeEdit',
      meta: { title: '询单编辑', headerBarShow: true, activeMenu: '/supplierPage/flyNotice' },
      hidden: true
    },
    {
      path: 'flyNoticeCreate',
      component: () => import('@/views/flyNotice/create/index'),
      name: 'flyNoticeCreate',
      meta: { title: '发起询单', headerBarShow: true, activeMenu: '/supplierPage/flyNotice' },
      hidden: true
    },
    {
      path: 'flyPriceDetail',
      component: () => import('@/views/flyPrice/detail/index'),
      name: 'flyPriceDetail',
      meta: { title: '询价详情', headerBarShow: true, activeMenu: '/supplierPage/flyPrice' },
      hidden: true
    },
    {
      path: 'flyPriceEdit',
      component: () => import('@/views/flyPrice/create/index'),
      name: 'flyPriceEdit',
      meta: { title: '询价编辑', headerBarShow: true, activeMenu: '/supplierPage/flyPrice' },
      hidden: true
    },
    {
      path: 'flyPriceCreate',
      component: () => import('@/views/flyPrice/create/index'),
      name: 'flyPriceCreate',
      meta: { title: '发起询价', headerBarShow: true, activeMenu: '/supplierPage/flyPrice' },
      hidden: true
    },
    {
      path: 'upOnlineDetail',
      component: () => import('@/views/upOnline/detail'),
      name: 'upOnlineDetail',
      meta: { title: '上刊详情', headerBarShow: true, activeMenu: '/supplierPage/upOnline' },
      hidden: true
    },
    {
      path: 'questionDetail/:id',
      component: () => import('@/views/question/detail'),
      name: 'questionDetail',
      meta: { title: '问题详情', headerBarShow: true, activeMenu: '/supplierPage/question' },
      hidden: true
    }
  ]
}];

export default supplierRouter;
